package com.yst.feign2.config;

import com.yst.feign2.interceptor.TestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorsConfigurer implements WebMvcConfigurer {

    @Autowired
    private TestInterceptor testInterceptor;

    /**
     * 注册拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns("/**") 表示拦截所有的请求
        // addPathPatterns("/**").excludePathPatterns("/login", "/register") 表示除了登陆与注册之外
        registry.addInterceptor(testInterceptor).addPathPatterns("/**");
    }
}
